<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      v-model.trim="addItem"
      @keyup.enter="addList"
    />
  </header>
</template>

<script>
export default {
   name: 'TodoHeader',
  data() {
    return {
      addItem: '',
    }
  },
  methods: {
    addList() {
      if (this.addItem.length === 0) return
      this.$emit('addList', this.addItem)
      this.addItem = ''
    },
  },
}
</script>

<style></style>
